//
//  CPSCServiceMarkTransverseView.m
//  CollTest
//
//  Created by codew on 9/12/21.
//

#import "CPSCServiceMarkTransverseView.h"

@interface CPSCServiceMarkTransverseView ()

@property (nonatomic, strong) UILabel * lblContent1;
@property (nonatomic, strong) UILabel * lblContent2;
@property (nonatomic, strong) UILabel * lblContent3;

@end


@implementation CPSCServiceMarkTransverseView


- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        
        [self initSubviews];
        [self makeContraints];
    }
    return self;
}

- (void)initSubviews
{
    [self addSubview:self.lblContent1];
    [self addSubview:self.lblContent2];
    [self addSubview:self.lblContent3];
    
    
    [self deBugUI];
}

- (void)makeContraints {
    
    CGFloat height = 14;
    [self.lblContent1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.left.mas_equalTo(0);
        make.height.mas_equalTo(height);
    }];
    
    [self.lblContent2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.mas_equalTo(0);
        make.left.equalTo(self.lblContent1.mas_right).offset(4);
        make.height.mas_equalTo(height);
    }];
    
    [self.lblContent3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.mas_equalTo(0);
        make.left.equalTo(self.lblContent2.mas_right).offset(4);
        make.height.mas_equalTo(height);
    }];
}

- (void)deBugUI
{
    //    self.viewHtmlContentSuper.backgroundColor = kCPSCRandomColor;
    //    self.lblContent.backgroundColor = kCPSCRandomColor;
}

- (void)updateViewWithItems:(NSArray <NSString *>*)items
{
    NSArray * arrLbl = @[self.lblContent1, self.lblContent2, self.lblContent3];
    for (UILabel * lblContent in arrLbl) {
        
        lblContent.hidden = YES;
    }
        
    for (int i = 0; i < items.count; i++) {
        
        if ( i < arrLbl.count) {
            UILabel * lblContent = arrLbl[i];
            lblContent.hidden = NO;
            lblContent.text = [NSString stringWithFormat:@" %@  ", items[i]];
        }
    }
    
}
#pragma mark - Getter Setter


- (UILabel *)lblContent1
{
    if (!_lblContent1) {

        UILabel * lblZy = [[UILabel alloc] init];
        lblZy.textColor = [UIColor colorWithHexString:@"#5C7499"];
        lblZy.font = [UIFont systemFontOfSize:10];
        lblZy.textAlignment = NSTextAlignmentCenter;
        lblZy.backgroundColor = [UIColor colorWithHexString:@"#F0F2F5"];
        lblZy.layer.cornerRadius = 2;
        lblZy.layer.masksToBounds = YES;
        
        _lblContent1 = lblZy;
    }
    
    return _lblContent1;
}

- (UILabel *)lblContent2
{
    if (!_lblContent2) {
        
        UILabel * lblZy = [[UILabel alloc] init];
        lblZy.textColor = [UIColor colorWithHexString:@"#5C7499"];
        lblZy.font = [UIFont systemFontOfSize:10];
        lblZy.textAlignment = NSTextAlignmentCenter;
        lblZy.backgroundColor = [UIColor colorWithHexString:@"#F0F2F5"];
        lblZy.layer.cornerRadius = 2;
        lblZy.layer.masksToBounds = YES;
        
        _lblContent2 = lblZy;
    }
    
    return _lblContent2;
}

- (UILabel *)lblContent3
{
    if (!_lblContent3) {

        UILabel * lblZy = [[UILabel alloc] init];
        lblZy.textColor = [UIColor colorWithHexString:@"#5C7499"];
        lblZy.font = [UIFont systemFontOfSize:10];
        lblZy.textAlignment = NSTextAlignmentCenter;
        lblZy.backgroundColor = [UIColor colorWithHexString:@"#F0F2F5"];
        lblZy.layer.cornerRadius = 2;
        lblZy.layer.masksToBounds = YES;
        
        _lblContent3 = lblZy;
    }
    
    return _lblContent3;
}

@end
